home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 / (Vol 132) Jun 09 2011.iso / Games / sushi-king.swf / scripts / frame_4 / DoAction.as
Encoding:
Text File  |  2011-06-09  |  10.1 KB  |  348 lines

  1. this.stop();
  2. FNscore = function(s, num)
  3. {
  4.    if(num < 0)
  5.    {
  6.       this.menu_mc.mark.gotoAndStop(2);
  7.    }
  8.    else
  9.    {
  10.       this.menu_mc.mark.gotoAndStop(1);
  11.    }
  12.    var _loc2_ = 1;
  13.    while(_loc2_ <= 5)
  14.    {
  15.       this.menu_mc[s + _loc2_].gotoAndStop(Math.floor(Math.abs(num) / Math.pow(10,_loc2_ - 1)) % 10 + 1);
  16.       _loc2_ = _loc2_ + 1;
  17.    }
  18. };
  19. mc_xpos = this.mc._x;
  20. mc_ypos = this.mc._y;
  21. this.mc.onPress = function()
  22. {
  23.    if(this._parent.player_mc._currentframe == 1)
  24.    {
  25.       this.gotoAndStop(2);
  26.       this.startDrag(false);
  27.    }
  28. };
  29. this.mc.onRelease = function()
  30. {
  31.    this.gotoAndStop(3);
  32.    this.stopDrag();
  33. };
  34. this.mc.onEnterFrame = function()
  35. {
  36.    if(this.hitTest(this._parent.clear_mc) && this._currentframe == 3)
  37.    {
  38.       var _loc2_ = 1;
  39.       while(_loc2_ <= 6)
  40.       {
  41.          this._parent.clear_mc.mc["m" + _loc2_].gotoAndStop(this._parent.dish[_loc2_]);
  42.          _loc2_ = _loc2_ + 1;
  43.       }
  44.       this._parent.clear_mc.gotoAndPlay(2);
  45.       this._x = this._parent.mc_xpos;
  46.       this._y = this._parent.mc_ypos;
  47.       this.gotoAndStop(1);
  48.    }
  49.    else if(this.hitTest(this._parent.rec) && this._currentframe == 3)
  50.    {
  51.       this._x = this._parent.mc_xpos;
  52.       this._y = this._parent.mc_ypos;
  53.       this.gotoAndStop(2);
  54.    }
  55. };
  56. number = new Array();
  57. FNmix = function()
  58. {
  59.    var _loc1_ = 0;
  60.    while(_loc1_ <= 11)
  61.    {
  62.       number[_loc1_] = _loc1_ + 1;
  63.       _loc1_ = _loc1_ + 1;
  64.    }
  65.    _loc1_ = 0;
  66.    while(_loc1_ < 30)
  67.    {
  68.       var _loc3_ = random(12);
  69.       var _loc2_ = random(12);
  70.       var _loc4_ = number[_loc3_];
  71.       number[_loc3_] = number[_loc2_];
  72.       number[_loc2_] = _loc4_;
  73.       _loc1_ = _loc1_ + 1;
  74.    }
  75. };
  76. FNpickup = function()
  77. {
  78.    this.player_mc.player.mc.m.gotoAndStop(name + 1);
  79. };
  80. FNputdown = function()
  81. {
  82.    total_pickup++;
  83.    dish[total_pickup] = name + 1;
  84.    FNscore("s",score);
  85.    this.mc["m" + total_pickup].gotoAndStop(name + 1);
  86. };
  87. FNchogi = function()
  88. {
  89.    level = 1;
  90.    FNscore("l",level);
  91.    score = 0;
  92.    FNscore("s",score);
  93.    game_ok = false;
  94.    this.text_mc.gotoAndStop("start");
  95.    xspeed = 2;
  96.    dish = new Array();
  97.    mc_depths = this.mc.getDepth();
  98.    menu_depths = this.menu_mc.getDepth();
  99.    link_depths = this.link_mc.getDepth();
  100.    this.mc.swapDepths(20);
  101.    this.menu_mc.swapDepths(21);
  102.    this.link_mc.swapDepths(22);
  103.    total_duplicate = total_mission = 5 + (level - 1);
  104.    total_success = 0;
  105.    move_num = 1;
  106.    depths = 1;
  107.    face_num = 1;
  108.    sell = [250,50,50,100,150,100,150,125,125,125,200,250];
  109. };
  110. FNchogi();
  111. FNduplicate = function()
  112. {
  113.    FNmix();
  114.    this.order_mc.duplicateMovieClip("order_mc" + depths,depths);
  115.    this["order_mc" + depths].number = new Array();
  116.    this["order_mc" + depths].total_number = 0;
  117.    this["order_mc" + depths].sell = 0;
  118.    this["order_mc" + depths].random_number = Math.ceil(level / 2) + random(3);
  119.    trace("number = " + number);
  120.    var _loc3_ = 1;
  121.    while(_loc3_ <= 6)
  122.    {
  123.       if(level > 6)
  124.       {
  125.          if(_loc3_ <= 4 + random(3))
  126.          {
  127.             this["order_mc" + depths].number[_loc3_] = number[_loc3_];
  128.             this["order_mc" + depths].total_number = this["order_mc" + depths].total_number + 1;
  129.             this["order_mc" + depths].sell += sell[number[_loc3_] - 1];
  130.          }
  131.          else
  132.          {
  133.             this["order_mc" + depths].number[_loc3_] = "blank";
  134.          }
  135.       }
  136.       else if(_loc3_ <= this["order_mc" + depths].random_number)
  137.       {
  138.          this["order_mc" + depths].number[_loc3_] = number[_loc3_] + 1;
  139.          this["order_mc" + depths].total_number = this["order_mc" + depths].total_number + 1;
  140.          this["order_mc" + depths].sell += sell[number[_loc3_] - 1];
  141.       }
  142.       else
  143.       {
  144.          this["order_mc" + depths].number[_loc3_] = "blank";
  145.       }
  146.       this["order_mc" + depths].move = true;
  147.       this["order_mc" + depths].move1 = true;
  148.       this["order_mc" + depths].total_ok = 0;
  149.       this["order_mc" + depths].duplicate_ok = true;
  150.       this["order_mc" + depths].mc.comp._visible = false;
  151.       _loc3_ = _loc3_ + 1;
  152.    }
  153.    this["order_mc" + depths].mc.order.gotoAndStop(this["order_mc" + depths].total_number);
  154.    this["order_mc" + depths].mc.comp.gotoAndStop(this["order_mc" + depths].total_number);
  155.    this["order_mc" + depths].onEnterFrame = function()
  156.    {
  157.       if(this.move && this._parent.game_ok)
  158.       {
  159.          if(this._x <= -100)
  160.          {
  161.             this.move = false;
  162.          }
  163.          if(this._x <= this._parent.order_mc._x - 150 && this.duplicate_ok)
  164.          {
  165.             if(this._parent.total_duplicate > 1)
  166.             {
  167.                this.duplicate_ok = false;
  168.                this._parent.total_duplicate--;
  169.                this._parent.FNduplicate();
  170.             }
  171.             else if(this.move1)
  172.             {
  173.                this.move1 = false;
  174.                this._parent["order_mc" + this._parent.move_num]._x = 560;
  175.                this._parent["order_mc" + this._parent.move_num].move = true;
  176.                this._parent["order_mc" + this._parent.move_num].move1 = true;
  177.                this._parent["order_mc" + this._parent.move_num].duplicate_ok = true;
  178.                if(this._parent.move_num < this._parent.total_mission)
  179.                {
  180.                   this._parent.move_num = this._parent.move_num + 1;
  181.                }
  182.                else
  183.                {
  184.                   this._parent.move_num = 1;
  185.                }
  186.             }
  187.          }
  188.          this._x -= this._parent.xspeed;
  189.          if(this._parent.mc._currentframe == 3)
  190.          {
  191.             if(this.hitTest(this._parent.mc))
  192.             {
  193.                if(this.mc._currentframe == 1)
  194.                {
  195.                   var _loc3_ = 1;
  196.                   while(_loc3_ <= 6)
  197.                   {
  198.                      if(_root.dish[_loc3_] != undefined)
  199.                      {
  200.                         if(_root.dish[_loc3_] == this.number[1] || _root.dish[_loc3_] == this.number[2] || _root.dish[_loc3_] == this.number[3] || _root.dish[_loc3_] == this.number[4] || _root.dish[_loc3_] == this.number[5] || _root.dish[_loc3_] == this.number[6])
  201.                         {
  202.                            this.total_ok = this.total_ok + 1;
  203.                         }
  204.                      }
  205.                      _loc3_ = _loc3_ + 1;
  206.                   }
  207.                   trace("length = " + (Number(_root.dish.length) - 1) + "            ,    number = " + this.total_number);
  208.                   if(this.total_ok == this.total_number && Number(_root.dish.length) - 1 == this.total_number)
  209.                   {
  210.                      if(this._parent.menu_mc.time_bar.bar._x < -10 * level)
  211.                      {
  212.                         this._parent.menu_mc.time_bar.bar._x += 10 * level;
  213.                      }
  214.                      else
  215.                      {
  216.                         this._parent.menu_mc.time_bar.bar._x = 0;
  217.                      }
  218.                      this._parent.score += this.sell;
  219.                      this._parent.FNscore("s",this._parent.score);
  220.                      this.mc.gotoAndPlay(2);
  221.                      this._parent.mc.gotoAndStop(1);
  222.                      this._parent.total_success = this._parent.total_success + 1;
  223.                   }
  224.                   else
  225.                   {
  226.                      this._parent.mc.gotoAndStop(2);
  227.                   }
  228.                   this.total_ok = 0;
  229.                   this._parent.mc._x = this._parent.mc_xpos;
  230.                   this._parent.mc._y = this._parent.mc_ypos;
  231.                }
  232.             }
  233.          }
  234.       }
  235.    };
  236.    depths++;
  237. };
  238. var i = 0;
  239. while(i <= 12)
  240. {
  241.    this["m" + i].onRollOver = function()
  242.    {
  243.       this.nextFrame();
  244.    };
  245.    this["m" + i].onRollOut = function()
  246.    {
  247.       this.prevFrame();
  248.    };
  249.    this["m" + i].onRelease = function()
  250.    {
  251.       if(this._parent.player_mc._currentframe == 1)
  252.       {
  253.          this.name = Number(this._name.substr(1,2));
  254.          if(this.name == 0 && this._parent.mc._currentframe == 1)
  255.          {
  256.             this._parent.total_pickup = 0;
  257.             this._parent.dish = new Array();
  258.             this._parent.dish[0] = "blank";
  259.             this._parent.mc.gotoAndStop(2);
  260.          }
  261.          if(this._parent.mc._currentframe == 2)
  262.          {
  263.             this._parent.name = this.name;
  264.             if(this.name >= 1 && this.name <= 7)
  265.             {
  266.                this._parent.player_mc.gotoAndStop("left");
  267.             }
  268.             if(this.name >= 8 && this.name <= 12)
  269.             {
  270.                this._parent.player_mc.gotoAndStop("right");
  271.             }
  272.          }
  273.       }
  274.    };
  275.    i++;
  276. }
  277. FNstart = function()
  278. {
  279.    game_ok = true;
  280.    FNduplicate();
  281.    this.order_mc1._x = this.order_mc._x - 50;
  282. };
  283. FNlevelup = function()
  284. {
  285.    FNclear();
  286.    this.menu_mc.time_bar.bar._x = 0;
  287.    level++;
  288.    FNscore("l",level);
  289.    total_duplicate = total_mission = 5 + (level - 1);
  290.    total_success = 0;
  291.    move_num = 1;
  292.    depths = 1;
  293. };
  294. FNgameover = function()
  295. {
  296.    FNclear();
  297.    this.mc.swapDepths(mc_depths);
  298.    this.menu_mc.swapDepths(menu_depths);
  299.    this.link_mc.swapDepths(link_depths);
  300.    this.gotoAndStop("gameover");
  301. };
  302. FNclear = function()
  303. {
  304.    var _loc2_ = 1;
  305.    while(_loc2_ <= total_mission)
  306.    {
  307.       this["order_mc" + _loc2_].gotoAndStop("clear");
  308.       _loc2_ = _loc2_ + 1;
  309.    }
  310. };
  311. time_i = 0.1;
  312. this.onEnterFrame = function()
  313. {
  314.    if(game_ok)
  315.    {
  316.       if(this.menu_mc.time_bar.bar._x < -176)
  317.       {
  318.          game_ok = false;
  319.          this.mc.swapDepths(mc_depths);
  320.          this.player_mc.gotoAndStop("bad");
  321.          this.text_mc.gotoAndStop("gameover");
  322.       }
  323.       else
  324.       {
  325.          this.menu_mc.time_bar.bar._x -= time_i;
  326.          trace(this.menu_mc.time_bar.bar._x);
  327.          if(this.menu_mc.time_bar.bar._x < -120)
  328.          {
  329.             face_num = 2;
  330.          }
  331.          else
  332.          {
  333.             face_num = 1;
  334.          }
  335.       }
  336.       if(total_success == total_mission && game_ok)
  337.       {
  338.          game_ok = false;
  339.          this.player_mc.gotoAndStop("good");
  340.          this.text_mc.gotoAndStop("levelup");
  341.       }
  342.    }
  343.    if(Key.isDown(32))
  344.    {
  345.       this.menu_mc.time_bar.bar._x = -174;
  346.    }
  347. };
  348.